package com.lideru.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lideru.blog.entity.Ad;
import com.lideru.blog.entity.Comment;
import com.lideru.blog.entity.User;
import com.lideru.blog.mapper.AdMapper;
import com.lideru.blog.mapper.UserMapper;
import com.lideru.blog.service.IAdService;
import com.lideru.blog.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

@Service
public class UserServiceImpl  extends ServiceImpl<UserMapper, User> implements IUserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(String username, String password) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<User>();
        queryWrapper.eq("username",username);
        queryWrapper.eq("password",password);
        queryWrapper.last("limit 1");
        List<User> list = userMapper.selectList(queryWrapper);
        if (userMapper.selectList(queryWrapper).size()>0){
            return list.get(0);
        };
        return null;
    }
}
